Exemplo n.º 1
0
  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();
  }
Exemplo n.º 2
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);
   }
 }
Exemplo n.º 3
0
 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);
   }
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 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());
 }
Exemplo n.º 6
0
 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);
   }
 }
Exemplo n.º 7
0
 private void handleLoadConfigCustButton() {
   xViewerToCustomize.getCustomizeMgr().loadCustomization(getConfigCustomizeCustData());
   xViewerToCustomize.refresh();
 }