Example #1
0
  @Override
  public boolean handleAltLeftClick(TreeColumn treeColumn, TreeItem treeItem) {
    try {
      if (treeItem.getData() instanceof Artifact) {
        Artifact useArt = (Artifact) treeItem.getData();
        if (useArt.isOfType(AtsArtifactTypes.Action)) {
          if (ActionManager.getTeams(useArt).size() == 1) {
            useArt = ActionManager.getFirstTeam(useArt);
          } else {
            return false;
          }
        }
        if (!(useArt instanceof AbstractWorkflowArtifact)) {
          return false;
        }
        AbstractWorkflowArtifact awa = (AbstractWorkflowArtifact) useArt;
        boolean modified = promptChangeAssignees(Arrays.asList(awa), isPersistViewer());
        XViewer xViewer = ((XViewerColumn) treeColumn.getData()).getTreeViewer();
        if (modified && isPersistViewer(xViewer)) {
          AtsChangeSet.execute("persist assignees via alt-left-click", awa);
        }
        if (modified) {
          xViewer.update(awa, null);
          return true;
        }
      }
    } catch (OseeCoreException ex) {
      OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
    }

    return false;
  }
Example #2
0
  @Override
  public boolean handleAltLeftClick(TreeColumn treeColumn, TreeItem treeItem) {
    try {
      if (treeItem.getData() instanceof Artifact) {
        Artifact useArt = (Artifact) treeItem.getData();
        if (!(useArt.isOfType(AtsArtifactTypes.AbstractWorkflowArtifact))) {
          return false;
        }

        boolean modified = promptChangeSprint(useArt, isPersistViewer());

        XViewer xViewer = ((XViewerColumn) treeColumn.getData()).getTreeViewer();
        if (modified && isPersistViewer(xViewer)) {
          useArt.persist("persist sprints via alt-left-click");
        }
        if (modified) {
          xViewer.update(useArt, null);
          return true;
        }
      }
    } catch (OseeCoreException ex) {
      OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
    }

    return false;
  }
  private void loadCustomizeTable() throws Exception {
    // Add stored customization data
    List<CustomizeData> custDatas = xViewerToCustomize.getCustomizeMgr().getSavedCustDatas();

    // Add table default customization data
    CustomizeData defaultTableCustData =
        xViewerToCustomize.getCustomizeMgr().getTableDefaultCustData();
    defaultTableCustData.setName(CustomizeManager.TABLE_DEFAULT_LABEL);
    custDatas.add(defaultTableCustData);

    // Add current customization data generated from actual table
    CustomizeData currentCustData =
        xViewerToCustomize.getCustomizeMgr().generateCustDataFromTable();
    currentCustData.setName(CustomizeManager.CURRENT_LABEL);
    custDatas.add(currentCustData);

    custTable.getViewer().setInput(custDatas);

    restoreCustTableSelection();

    // If selection not restored, select default
    if (getCustTableSelection() == null) {
      ArrayList<Object> sel = new ArrayList<Object>();
      sel.add(currentCustData);
      custTable
          .getViewer()
          .setSelection(new StructuredSelection(sel.toArray(new Object[sel.size()])));
      custTable.getViewer().getTree().setFocus();
    }

    updateSortTextField();
    updateColumnFilterField();
    updateButtonEnablements();
  }
Example #4
0
 private void getInput(Control c) {
   if (InInput) {
     return;
   }
   if (klickedCell == null) {
     return;
   }
   XViewerColumn xCol =
       xv.getXViewerFactory()
           .getDefaultXViewerColumn(((XViewerColumn) klickedColumn.getData()).getId());
   if (xCol instanceof ExtendedViewerColumn) {
     ExtendedViewerColumn extendedCol = (ExtendedViewerColumn) xCol;
     CellEditDescriptor ced =
         extendedCol.getCellEditDescriptorMap().get(klickedCell.getElement().getClass());
     if (ced == null || ced.getControl() == null) {
       return;
     }
     InInput = true;
     try {
       converter.getInput(c, ced, klickedCell.getElement());
       xv.refresh(klickedCell.getElement());
     } catch (Exception ex) {
       InInput = false;
     }
     InInput = false;
   }
 }
 private void handleDeleteButton() {
   try {
     CustomizeData custSel = getCustTableSelection();
     if (custSel.getName().equals(CustomizeManager.TABLE_DEFAULT_LABEL)
         || custSel.getName().equals(CustomizeManager.CURRENT_LABEL)) {
       XViewerLib.popup("ERROR", XViewerText.get("error.delete_default"));
       return;
     }
     if (!custSel.isPersonal() && !xViewerToCustomize.getXViewerFactory().isAdmin()) {
       XViewerLib.popup("ERROR", XViewerText.get("error.delete_global"));
       return;
     }
     if (MessageDialog.openConfirm(
         Display.getCurrent().getActiveShell(),
         XViewerText.get("XViewerCustomizeDialog.prompt.delete.title"),
         MessageFormat.format(
             XViewerText.get("XViewerCustomizeDialog.prompt.delete"), custSel.getName()))) {
       xViewerToCustomize.getCustomizeMgr().deleteCustomization(custSel);
       loadCustomizeTable();
       updateButtonEnablements();
     }
   } catch (Exception ex) {
     XViewerLog.logAndPopup(Activator.class, Level.SEVERE, ex);
   }
 }
 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);
   }
 }
  @Override
  public void mouseDoubleClick(MouseEvent event) {
    Point point = new Point(event.x, event.y);
    TreeColumn column = xViewer.getColumnUnderMouseClick(point);
    TreeItem itemToReturn = xViewer.getItemUnderMouseClick(point);

    xViewer.handleDoubleClick(column, itemToReturn);
  }
Example #8
0
  public void activate(final XViewer xv) {
    this.xv = xv;

    mouseListener = new MyMouseListener(swtEvent);
    xv.getTree().addMouseListener(mouseListener);

    selListener = new MyListener();
    xv.getTree().addListener(SWT.Selection, selListener);
  }
 private void updateButtonEnablements() {
   CustomizeData custData = getCustTableSelection();
   setDefaultButton.setEnabled(
       xViewerToCustomize
               .getXViewerFactory()
               .getXViewerCustomizations()
               .isCustomizationPersistAvailable()
           && custTable.getViewer().getTree().isFocusControl()
           && custData != null
           && !custData.getName().equals(CustomizeManager.TABLE_DEFAULT_LABEL)
           && !custData.getName().equals(CustomizeManager.CURRENT_LABEL));
   if (custTable.getViewer().getTree().isFocusControl() && custData != null) {
     try {
       setDefaultButton.setText(
           xViewerToCustomize.getCustomizeMgr().isCustomizationUserDefault(custData)
               ? REMOVE_DEFAULT
               : SET_AS_DEFAULT);
     } catch (XViewerException ex) {
       XViewerLog.log(Activator.class, Level.SEVERE, ex);
     }
     setDefaultButton.getParent().layout();
   }
   deleteButton.setEnabled(
       xViewerToCustomize
               .getXViewerFactory()
               .getXViewerCustomizations()
               .isCustomizationPersistAvailable()
           && custTable.getViewer().getTree().isFocusControl()
           && custData != null);
   addItemButton.setEnabled(
       hiddenColTable.getViewer().getTree().isFocusControl() && getHiddenTableSelection() != null);
   removeItemButton.setEnabled(
       visibleColTable.getViewer().getTree().isFocusControl()
           && getVisibleTableSelection() != null);
   renameButton.setEnabled(
       visibleColTable.getViewer().getTree().isFocusControl()
           && getVisibleTableSelection() != null
           && getVisibleTableSelection().size() == 1);
   moveDownButton.setEnabled(
       visibleColTable.getViewer().getTree().isFocusControl()
           && getVisibleTableSelection() != null);
   moveUpButton.setEnabled(
       visibleColTable.getViewer().getTree().isFocusControl()
           && getVisibleTableSelection() != null);
   saveButton.setEnabled(
       xViewerToCustomize.getXViewerFactory().getXViewerCustomizations() != null
           && xViewerToCustomize
               .getXViewerFactory()
               .getXViewerCustomizations()
               .isCustomizationPersistAvailable());
 }
 private boolean clickOccurredInIconArea(MouseEvent event, TreeItem item) {
   Integer columnNumber = xViewer.getColumnNumberUnderMouseClick(new Point(event.x, event.y));
   if (columnNumber == null) {
     return false;
   }
   Rectangle rect = item.getBounds(columnNumber);
   return (event.x <= (rect.x + 18));
 }
 @Override
 public void mouseDown(MouseEvent event) {
   if (isLeftClick(event)) {
     leftClickEvent = event;
   }
   if (isRightClick(event)) {
     xViewer.processRightClickMouseEvent(new Point(event.x, event.y));
   }
 }
 /** @return CustomizeData represented by the configuration area */
 private CustomizeData getConfigCustomizeCustData() {
   CustomizeData custData = new CustomizeData();
   custData.resetGuid();
   custData.setNameSpace(xViewerToCustomize.getXViewerFactory().getNamespace());
   custData.getColumnData().setColumns(getConfigCustXViewerColumns());
   custData.getSortingData().setFromXml(sorterText.getText());
   custData
       .getFilterData()
       .setFilterText(filterText.getText(), filterRegExCheckBox.getSelection());
   custData.getColumnFilterData().setFromXml(columnFilterText.getText());
   return custData;
 }
  @Override
  public void mouseUp(MouseEvent event) {
    TreeItem item = xViewer.getItemUnderMouseClick(new Point(event.x, event.y));
    if (item == null) {
      return;
    }

    try {
      TreeColumn column = xViewer.getColumnUnderMouseClick(new Point(event.x, event.y));
      if (column == null) {
        return;
      }
      if (isLeftClick(event) && controlNotBeingHeld(event)) {

        if (altIsBeingHeld(event)) {
          // System.out.println("Column " + colNum);
          xViewer.handleAltLeftClick(column, item);
        } else if (clickOccurredInIconArea(event, item)) {
          xViewer.handleLeftClickInIconArea(column, item);
        } else {
          // System.out.println("Column " + colNum);
          xViewer.handleLeftClick(column, item);
        }
      }
      xViewer.updateStatusLabel();
    } catch (ArrayIndexOutOfBoundsException ex) {
      // mouse clicked outside of last/valid column
      return;
    }
  }
 private void handleRenameButton() {
   XViewerColumn xCol = getVisibleTableSelection().iterator().next();
   DialogWithEntry ed =
       new DialogWithEntry(
           Display.getCurrent().getActiveShell(),
           "Rename Column",
           null,
           "Enter new name",
           MessageDialog.QUESTION,
           new String[] {"OK", "Use Default", "Cancel"},
           0);
   int result = ed.open();
   if (result == 2) {
     return;
   }
   if (result == 0) {
     xViewerToCustomize.getCustomizeMgr().customizeColumnName(xCol, ed.getEntry());
   } else if (result == 1) {
     xViewerToCustomize.getCustomizeMgr().customizeColumnName(xCol, "");
   }
   visibleColTable.getViewer().update(xCol, null);
 }
 private void handleSaveButton() {
   try {
     List<CustomizeData> custDatas = new ArrayList<CustomizeData>();
     for (CustomizeData custData : xViewerToCustomize.getCustomizeMgr().getSavedCustDatas()) {
       if (custData.isPersonal()) {
         custDatas.add(custData);
       } else if (xViewerToCustomize.getXViewerFactory().isAdmin()) {
         custDatas.add(custData);
       }
     }
     CustomizationDataSelectionDialog diag =
         new CustomizationDataSelectionDialog(xViewerToCustomize, custDatas);
     if (diag.open() == 0) {
       String name = diag.getEnteredName();
       try {
         CustomizeData diagSelectedCustomizeData = diag.getSelectedCustData();
         String diagEnteredNewName = diag.getEnteredName();
         CustomizeData custData = getConfigCustomizeCustData();
         if (diagEnteredNewName != null) {
           custData.setName(name);
           // Set currently selected to newly saved custData
           selectedCustTableCustData = custData;
         } else {
           custData.setName(diagSelectedCustomizeData.getName());
           custData.setGuid(diagSelectedCustomizeData.getGuid());
         }
         custData.setPersonal(!diag.isSaveGlobal());
         xViewerToCustomize.getCustomizeMgr().saveCustomization(custData);
       } catch (Exception ex) {
         XViewerLog.logAndPopup(Activator.class, Level.SEVERE, ex);
       }
     }
     loadCustomizeTable();
   } catch (Exception ex) {
     XViewerLog.logAndPopup(Activator.class, Level.SEVERE, ex);
   }
 }
Example #16
0
 private void setInput(Control c) {
   if (klickedCell == null) {
     return;
   }
   XViewerColumn xCol =
       xv.getXViewerFactory()
           .getDefaultXViewerColumn(((XViewerColumn) klickedColumn.getData()).getId());
   if (xCol instanceof ExtendedViewerColumn) {
     ExtendedViewerColumn extendedCol = (ExtendedViewerColumn) xCol;
     CellEditDescriptor ced =
         extendedCol.getCellEditDescriptorMap().get(klickedCell.getElement().getClass());
     if (ced == null || ced.getControl() == null) {
       return;
     }
     converter.setInput(c, ced, klickedCell.getElement());
   }
   c.setBounds(klickedCell.getBounds());
 }
  @Override
  protected Control createDialogArea(Composite parent) {
    if (getShell() != null) {
      getShell().setText(title);
    }
    parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Composite comp = new Composite(parent, SWT.NONE);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.heightHint = 700;
    comp.setLayoutData(gd);
    GridLayout gridLayout_2 = new GridLayout();
    gridLayout_2.numColumns = 2;
    comp.setLayout(gridLayout_2);

    Label namespaceLabel = new Label(comp, SWT.NONE);
    GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, false, false);
    gridData.horizontalSpan = 2;
    namespaceLabel.setLayoutData(gridData);
    namespaceLabel.setText(
        MessageFormat.format(
            XViewerText.get("namespace"), xViewerToCustomize.getXViewerFactory().getNamespace()));

    createSelectCustomizationSection(comp);

    // Column Configuration
    Group configureColumnsGroup = new Group(comp, SWT.NONE);
    configureColumnsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
    configureColumnsGroup.setText("Configure Customization");
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginWidth = 3;
    gridLayout.marginHeight = 3;
    gridLayout.numColumns = 3;
    configureColumnsGroup.setLayout(gridLayout);

    createHiddenButtonsComposition(configureColumnsGroup);
    createMoveButtons(configureColumnsGroup);
    createVisibleButtonsComposition(configureColumnsGroup);

    gridLayout.numColumns = 3;
    gridLayout.numColumns = 3;

    // Create Sorter and Filter Blocks
    final Composite composite_2 = new Composite(configureColumnsGroup, SWT.NONE);
    composite_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
    final GridLayout gridLayout_3 = new GridLayout();
    gridLayout_3.numColumns = 3;
    composite_2.setLayout(gridLayout_3);

    createSorterTextBlock(composite_2);
    createFilterTextBlock(composite_2);
    createColumnFilterTextBlock(composite_2);

    createConfigCustomizationButtonBar(composite_2);

    try {
      loadCustomizeTable();
    } catch (Exception ex) {
      XViewerLog.logAndPopup(Activator.class, Level.SEVERE, ex);
    }
    updateButtonEnablements();

    return comp;
  }
 private void handleLoadConfigCustButton() {
   xViewerToCustomize.getCustomizeMgr().loadCustomization(getConfigCustomizeCustData());
   xViewerToCustomize.refresh();
 }